package com.github.niefy.modules.wx.controller;

import com.github.niefy.modules.wx.service.DataAnalyzeService;
import me.chanjar.weixin.mp.bean.datacube.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/DataAnalyze")
@CrossOrigin
public class DataAnalyzeController{
    @Autowired
    private DataAnalyzeService dataAnalyzeService;

    /**
     * 获取新增用户数
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUserSummary")
    public List<WxDataCubeUserSummary> getUserSummary(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUserSummary(startDate, endDate);
    }

    /**
     * 获取累计用户数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUserCumulate")
    public List<WxDataCubeUserCumulate> getUserCumulate(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUserCumulate(startDate, endDate);
    }

    /**
     * 获取图文群发每日数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getArticleSummary")
    public List<WxDataCubeArticleResult> getArticleSummary(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getArticleSummary(startDate, endDate);
    }

    /**
     *  获取图文群发总数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getArticleTotal")
    public List<WxDataCubeArticleTotal> getArticleTotal(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getArticleTotal(startDate, endDate);
    }

    /**
     * 获取图文统计数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUserRead")
    public List<WxDataCubeArticleResult> getUserRead(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUserRead(startDate, endDate);
    }

    /**
     * 获取图文统计分时数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUserReadHour")
    public List<WxDataCubeArticleResult> getUserReadHour(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUserReadHour(startDate, endDate);
    }

    /**
     * 获取图文分享转发数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUserShare")
    public List<WxDataCubeArticleResult> getUserShare(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUserShare(startDate, endDate);
    }

    /**
     * 获取图文分享转发分时数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUserShareHour")
    public List<WxDataCubeArticleResult> getUserShareHour(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUserShareHour(startDate, endDate);
    }

    /**
     * 获取消息发送概况数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUpstreamMsg")
    public List<WxDataCubeMsgResult> getUpstreamMsg(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUpstreamMsg(startDate, endDate);
    }

    /**
     * 获取消息分送分时数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUpstreamMsgHour")
    public List<WxDataCubeMsgResult> getUpstreamMsgHour(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUpstreamMsgHour(startDate, endDate);
    }

    /**
     * 获取消息发送周数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUpstreamMsgWeek")
    public List<WxDataCubeMsgResult> getUpstreamMsgWeek(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUpstreamMsgWeek(startDate, endDate);
    }

    /**
     * 获取消息发送月数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUpstreamMsgMonth")
    public List<WxDataCubeMsgResult> getUpstreamMsgMonth(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUpstreamMsgMonth(startDate, endDate);
    }

    /**
     * 获取消息发送分布数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUpstreamMsgDist")
    public List<WxDataCubeMsgResult> getUpstreamMsgDist(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUpstreamMsgDist(startDate, endDate);
    }

    /**
     * 获取消息发送分布周数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUpstreamMsgDistWeek")
    public List<WxDataCubeMsgResult> getUpstreamMsgDistWeek(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUpstreamMsgDistWeek(startDate, endDate);
    }

    /**
     * 获取消息发送分布月数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getUpstreamMsgDistMonth")
    public List<WxDataCubeMsgResult> getUpstreamMsgDistMonth(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getUpstreamMsgDistMonth(startDate, endDate);
    }

    /**
     * 获取接口分析数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getInterfaceSummary")
    public List<WxDataCubeInterfaceResult> getInterfaceSummary(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getInterfaceSummary(startDate, endDate);
    }

    /**
     * 获取接口分析分时数据
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getInterfaceSummaryHour")
    public List<WxDataCubeInterfaceResult> getInterfaceSummaryHour(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        return dataAnalyzeService.getInterfaceSummaryHour(startDate, endDate);
    }
}
